package cn.com.gzheroli.rabbitmq.service.producer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by lhx on 2016/9/5 9:56
 *
 * @Description
 */
@Service("messageProducerService")
public class MessageProducerService {

    private Logger logger = LoggerFactory.getLogger(MessageProducerService.class);

    /*@Resource
    private AmqpTemplate amqpTemplate;*/
    @Autowired
    private RabbitTemplate template;

    public void  sendMessage(Object message){
        logger.info("to send message:{}",message);
        //amqpTemplate.convertAndSend("queueTestKey",message);
        String exchange=template.getExchange();
        String routingKey="ccs.binding.async";
        routingKey="ccs.binding.log.async";
        //routingKey="ccs.queue.async";
        //amqpTemplate.convertAndSend(exchange, routingKey, message);
        template.convertAndSend(template.getExchange(),routingKey ,message);
    }
}
